package com.bs.kafka.config;

import org.apache.kafka.clients.admin.NewTopic;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author bingshao
 * @date 2022/10/10
 **/
@Configuration
public class KafkaConfig {

    @Bean
    public NewTopic test1() {
        return new NewTopic("test1", 1, (short) 1);
    }

    @Bean
    public NewTopic test1DLT() {
        return new NewTopic("test1.DLT", 1, (short) 1);
    }

    // flink接收的队列
    @Bean
    public NewTopic flinkTest() {
        return new NewTopic("flink-test", 1, (short) 1);
    }

    // flink发送的队列
    @Bean
    NewTopic flinkSend() {
        return new NewTopic("flink-send", 1, (short) 1);
    }

    // 测试所用
    @Bean
    public NewTopic testTopic() {
        return new NewTopic("test-topic", 1, (short) 1);
    }


//    @Bean
//    @Primary
//    public BatchErrorHandler kafkaBatchErrorHandler() {
//        // 创建 SeekToCurrentBatchErrorHandler 对象
//        SeekToCurrentBatchErrorHandler batchErrorHandler = new SeekToCurrentBatchErrorHandler();
//        // 创建 FixedBackOff 对象
//        BackOff backOff = new FixedBackOff(10 * 1000L, 3L);
//        batchErrorHandler.setBackOff(backOff);
//        // 返回
//        return batchErrorHandler;
//    }

}
